package com.hp.interview.concurrent.threads_run_in_order;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author libo
 * 通过SingleThreadExecutor让线程按顺序执行
 */
public class ThreadPoolDemo {

    static ExecutorService executorService = Executors.newSingleThreadExecutor();

    public static void main(String[] args) throws Exception {
        final Thread thread1 = new Thread(() -> System.out.println("产品经理规划新需求"));
        final Thread thread2 = new Thread(() -> System.out.println("开发人员开发新需求功能"));
        final Thread thread3 = new Thread(() -> System.out.println("测试人员测试新功能"));

        executorService.submit(thread1);
        executorService.submit(thread2);
        executorService.submit(thread3);
        executorService.shutdown();
    }
}